var t, a = require("./@babel/runtime/helpers/interopRequireDefault"), e = a(require("./@babel/runtime/regenerator")), o = a(require("./@babel/runtime/helpers/asyncToGenerator"));

Page({
    data: {
        ocr_type: "",
        danNum: "",
        toustState: !1,
        currentWordNumber: !1
    },
    onLoad: function(t) {
        console.log(t);
        var a = t.ocr_type;
        console.log(a), this.setData({
            ocr_type: a
        }), 1 == a ? wx.setNavigationBarTitle({
            title: "手机号查询"
        }) : 2 == a ? wx.setNavigationBarTitle({
            title: "身份证查询"
        }) : 3 == a ? wx.setNavigationBarTitle({
            title: "银行卡查询"
        }) : 4 == a && wx.setNavigationBarTitle({
            title: "IP查询"
        });
    },
    inputDanNum: function(t) {
        console.log(t.detail.value);
        this.setData({
            danNum: t.detail.value
        }), "" == t.detail.value ? this.setData({
            currentWordNumber: !1
        }) : this.setData({
            currentWordNumber: !0
        });
    },
    clear: function() {
        this.setData({
            danNum: ""
        });
    },
    selectPhone: (t = (0, o.default)(e.default.mark(function t(a) {
        var o, d, n;
        return e.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                return o = this, t.next = 3;

              case 3:
                if (t.sent) {
                    t.next = 6;
                    break;
                }
                return t.abrupt("return");

              case 6:
                "" !== o.data.danNum ? 1 == o.data.ocr_type ? /^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(o.data.danNum) ? (wx.showLoading({
                    title: "查询中",
                    mask: !0
                }), wx.request({
                    url: "https://api.jozoe.com.cn/apis/phone",
                    method: "post",
                    data: {
                        num: o.data.danNum
                    },
                    success: function(t) {
                        if (200 == t.statusCode) {
                            wx.hideLoading();
                            var a = {
                                ocr_type: o.data.ocr_type,
                                phoneNum: o.data.danNum,
                                data: t.data
                            };
                            wx.navigateTo({
                                url: "/pages/tools/address/showAddCha",
                                success: function(t) {
                                    wx.hideLoading(), t.eventChannel.emit("data", a);
                                }
                            });
                        }
                    }
                })) : wx.showToast({
                    title: "手机号码输入错误！",
                    icon: "none",
                    duration: 2e3
                }) : 2 == o.data.ocr_type ? (d = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, 
                n = /^[1-9][0-7]\d{4}/, o.data.danNum.length > 6 ? d.test(o.data.danNum) ? (wx.showLoading({
                    title: "查询中",
                    mask: !0
                }), wx.request({
                    url: "https://api.jozoe.com.cn/apis/idcard",
                    method: "post",
                    data: {
                        idcard: o.data.danNum
                    },
                    success: function(t) {
                        if (wx.hideLoading(), 200 == t.statusCode) {
                            wx.hideLoading();
                            var a = {
                                ocr_type: o.data.ocr_type,
                                idNum: o.data.danNum,
                                data: t.data.result
                            };
                            wx.navigateTo({
                                url: "/pages/tools/address/showAddCha",
                                success: function(t) {
                                    wx.hideLoading(), t.eventChannel.emit("data", a);
                                }
                            });
                        }
                    }
                })) : wx.showToast({
                    title: "身份证号码输入错误！",
                    icon: "none",
                    duration: 2e3
                }) : n.test(o.data.danNum) ? (wx.showLoading({
                    title: "查询中",
                    mask: !0
                }), wx.request({
                    url: "https://api.jozoe.com.cn/apis/idcard",
                    method: "post",
                    data: {
                        idcard: o.data.danNum
                    },
                    success: function(t) {
                        if (wx.hideLoading(), console.log(t), 200 == t.statusCode) {
                            wx.hideLoading();
                            var a = {
                                ocr_type: o.data.ocr_type,
                                idNum: o.data.danNum,
                                data: t.data.result
                            };
                            wx.navigateTo({
                                url: "/pages/tools/address/showAddCha",
                                success: function(t) {
                                    wx.hideLoading(), t.eventChannel.emit("data", a);
                                }
                            });
                        }
                    }
                })) : wx.showToast({
                    title: "身份证前六位输入错误！",
                    icon: "none",
                    duration: 2e3
                })) : 3 == o.data.ocr_type ? /^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(o.data.danNum) ? (wx.showLoading({
                    title: "查询中",
                    mask: !0
                }), wx.request({
                    url: "https://api.jozoe.com.cn/apis/bankcard",
                    method: "post",
                    data: {
                        bankcard: o.data.danNum
                    },
                    success: function(t) {
                        if (200 == t.data.code) {
                            wx.hideLoading();
                            var a = {
                                ocr_type: o.data.ocr_type,
                                backNum: o.data.danNum,
                                data: t.data.data
                            };
                            wx.navigateTo({
                                url: "/pages/tools/address/showAddCha",
                                success: function(t) {
                                    wx.hideLoading(), t.eventChannel.emit("data", a);
                                }
                            });
                        }
                    }
                })) : wx.showToast({
                    title: "银行卡号输入错误！",
                    icon: "none",
                    duration: 2e3
                }) : 4 == o.data.ocr_type && (/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(o.data.danNum) ? (wx.showLoading({
                    title: "查询中",
                    mask: !0
                }), wx.request({
                    url: "https://api.jozoe.com.cn/apis/ip",
                    method: "post",
                    data: {
                        ip: o.data.danNum
                    },
                    success: function(t) {
                        if (200 == t.statusCode) {
                            wx.hideLoading();
                            var a = {
                                ocr_type: o.data.ocr_type,
                                ip: o.data.danNum,
                                data: t.data.result
                            };
                            wx.navigateTo({
                                url: "/pages/tools/address/showAddCha",
                                success: function(t) {
                                    wx.hideLoading(), t.eventChannel.emit("data", a);
                                }
                            });
                        }
                    }
                })) : wx.showToast({
                    title: "IP输入错误！",
                    icon: "none",
                    duration: 2e3
                })) : wx.showModal({
                    title: "查询失败",
                    content: "请填写后重试！"
                });

              case 7:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(a) {
        return t.apply(this, arguments);
    }),
    scan: function() {
        var t = this;
        wx.scanCode({
            success: function(a) {
                console.log("扫码结果"), console.log(a);
                var e = a.result;
                t.setData({
                    danNum: e
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onShow: function() {
        "" == this.data.danNum && this.setData({
            currentWordNumber: !1
        });
    },
    onShareAppMessage: function(t) {
        var a = this.data.ocr_type;
        this.setData({
            imageUrl: "http://file.scjrh.net/hammer/tools.png",
            title: "给你分享一个归属地查询的好工具",
            path: "pages/addCha/addCha?ocr_type=" + a
        });
        var e = {
            title: this.data.title,
            path: this.data.path,
            imageUrl: this.data.imageUrl,
            success: function(t) {
                t.errMsg;
            },
            fail: function() {
                "shareAppMessage:fail cancel" == res.errMsg || res.errMsg;
            }
        };
        return t.from, e;
    },
    onShareTimeline: function() {
        return 1 == this.data.ocr_type ? {
            title: "给大家推荐一个手机号查询工具：锤子工具人。",
            imageUrl: "http://file.scjrh.net/hammer/logo.png"
        } : 2 == this.data.ocr_type ? {
            title: "给大家推荐一个身份证查询工具：锤子工具人。",
            imageUrl: "http://file.scjrh.net/hammer/logo.png"
        } : 3 == this.data.ocr_type ? {
            title: "给大家推荐一个银行卡查询工具：锤子工具人。",
            imageUrl: "http://file.scjrh.net/hammer/logo.png"
        } : 4 == this.data.ocr_type ? {
            title: "给大家推荐一个ip查询工具：锤子工具人。",
            imageUrl: "http://file.scjrh.net/hammer/logo.png"
        } : void 0;
    }
});